<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>


    <link href="/ajax/libs/smartwizard/smart_wizard_all.min.css" rel="stylesheet"/>

    <th:block th:include="include :: header('对接导师')" />
    <style type="text/css">
        /* 如果要让工具栏固定在页面底部,使用下面的样式,不需要的可以注释 */
        /*.sw>.toolbar-bottom{*/
            /*z-index: 100;*/
            /*bottom: 0;*/
            /*left: 0;*/
            /*width: 100%;*/
            /*position: fixed;*/
            /*text-align: right;*/
            /*background: #fff;*/
            /*box-shadow: 0 -2px 6px 1px hsla(223,8%,83%,.5);*/
            /*border-top: 1px solid #e3e4e8;*/
        /*}*/
        /* 如果设置了是否自动调节高度为false,需要加滚动条 */
        .sw>.tab-content{
            overflow-x: hidden;
            overflow-y: auto;
            height: 80% !important;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight" style="height: 100%;">
    <div class="row">
        <div class="col-sm-12">
            <div id="smartwizard">
                <ul class="nav">
                    <li class="nav-item">
                        <a class="nav-link" href="#step-1"> 选择 </a>
                    </li>
                </ul>
                <div class="tab-content" style="height: 80%">
                    <div id="step-1" class="tab-pane" role="tabpanel" aria-labelledby="step-1">
                        <div>
                            <form class="form form-horizontal m-t">

                                <div class="form-group">
                                    <label class="col-sm-3 control-label is-required">姓名：</label>
                                    <div class="col-sm-8">
                                        <input id="tea1Name" name="tea1Name" class="form-control" type="text" required readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label is-required">工号：</label>
                                    <div class="col-sm-8">
                                        <input id="tea1Jno" name="tea1Jno" class="form-control" type="text" required readonly="readonly">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label is-required">理由：</label>
                                    <div class="col-sm-8">
                                        <textarea id="intention1" name="intention1" class="form-control"  style="resize: vertical" required></textarea>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="row">
                            <div class="col-sm-12 select-table table-striped">
                                <table id="bootstrap-table"></table>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>

    </div>
</div>



<script> var ctx = "\/"; var lockscreen = null; if(lockscreen){window.top.location=ctx+"lockscreen";} </script>
<a id="scroll-up" href="#" class="btn btn-sm display"><i class="fa fa-angle-double-up"></i></a>

<th:block th:include="include :: footer" />

<script src="/ajax/libs/smartwizard/jquery.smartWizard.min.js"></script>


<script th:inline="javascript">
    var teaSexDatas = [[${@dict.getType('sys_user_sex')}]];
    var prefix = ctx + "system/tea";

    $(function() {
        var options = {
            url: prefix + "/list",
            onDblClickRow: onDblClickRow1,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            columns: [
                {
                    field: 'teaJno',
                    title: '工号'
                },
                {
                    field: 'teaName',
                    title: '姓名'
                },
                {
                    field: 'teaSex',
                    title: '性别',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(teaSexDatas, value);
                    }
                },
                {
                    field: 'teaPhone',
                    title: '电话'
                },
                {
                    field: 'teaSkill',
                    title: '特长'
                },
                {
                    field: 'teaTitle',
                    title: '职称'
                }]
        };
        $.table.init(options);

    });
</script>


<script>
    $(document).ready(function() {
        // 工具栏按钮
        var btnFinish = $('<a id="btn-finish"></a>').text('完成')
            .addClass('btn btn-info')
            .on('click', function(){ submit(); });
        var btnCancel = $('<a id="btn-cancel"></a>').text('取消')
            .addClass('btn btn-danger')
            .on('click', function(){ $('#smartwizard').smartWizard("reset"); });
        //下面两个按钮是为了因为插件默认的是botton,这里换成<a>,也可以选择用样式替换,或者不替换
        var btnNext = $('<a id="btn-next"></a>').text('下一步')
            .addClass('btn btn-info disabled ')
            .on('click', function(){ $('#smartwizard').smartWizard("next");});
        var btnPrev = $('<a id="btn-prev"></a>').text('上一步')
            .addClass('btn btn-success disabled')
            .on('click', function(){ $('#smartwizard').smartWizard("prev"); });
        //初始化表单向导组件
        $('#smartwizard').smartWizard({
            theme: 'arrows', // default, arrows, dots, progress
            autoAdjustHeight : true, // 自动调整高度, 默认true
            enableURLhash:true, //开启URL hash,开启后点击浏览器前进后退按钮会执行下一步和上一步操作
            transition: {
                animation: 'slide-horizontal' // Effect on navigation, none/fade/slide-horizontal/slide-vertical/slide-swing
            },
            toolbarSettings: {
                showNextButton: false,// 因为上面自定义了下一步按钮, 所以隐藏掉插件自带的按钮, 如果不使用自定义按钮, 需要改为true或者去掉该属性
                showPreviousButton: false,// 因为上面自定义了上一步按钮, 所以隐藏掉插件自带的按钮, 如果不使用自定义按钮, 需要改为true或者去掉该属性
                toolbarExtraButtons: [btnCancel,btnPrev,btnNext,btnFinish]// 扩展的按钮集合
            }
        });
    });

    function onDblClickRow1(row, $element){
        document.getElementById("tea1Name").value=row.teaName;
        document.getElementById("tea1Jno").value=row.teaJno;
    }

    function submit(){
        var form = $("#step-1").find('.form');
        if(form.length > 0){
            if(form.validate().form())
            {
                var data = {};
                $('.form').each(function (index, form){
                    // 这里可以使用$.common.formToJSON(formId);  需要在form上加id
                    $.each($(form).serializeArray(), function(i, field) {
                        if(field.name !="tea1Name")
                        {
                            if(data[field.name]) {
                                data[field.name] += ("," + field.value);
                            } else {
                                data[field.name] = field.value;
                            }
                        }
                    });
                });
                $.operate.post(ctx+ "system/tutor/editTeaOne", data);
                this.close();
            }
        }


    }

    $("#reset-btn").on("click", function() {
        // Reset wizard
        $('#smartwizard').smartWizard("reset");
        return true;
    });



</script>
</body>
</html>
